home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
moving1a
/
form1.frm
next >
Wrap
Text File
|
1999-08-26
|
4KB
|
119 lines
VERSION 5.00
Begin VB.Form Form1
Caption = "DasherSW's Moving Caption Sample..."
ClientHeight = 525
ClientLeft = 60
ClientTop = 345
ClientWidth = 4875
LinkTopic = "Form1"
MaxButton = 0 'False
Moveable = 0 'False
ScaleHeight = 525
ScaleWidth = 4875
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Left = 0
Top = 0
End
Begin VB.CommandButton Start
Caption = "Start"
Height = 495
Left = 420
TabIndex = 0
Top = 0
Width = 1215
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "You can place Start_Click in Form_Load so that it starts to move just after form is loaded."
Height = 435
Left = 1680
TabIndex = 1
Top = 60
Width = 3135
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Rem Code by DasherSW. 'Hope i' will teach u some.
Rem know this variables declared at first will always work
Rem faster than getting the needed value at run time.
Rem Const values cannot change.
Rem
Rem declarations
Rem
Rem the amount of spaces the caption will move left
Const CapSpace As Integer = 10
Rem the interval of the timer
Const TimerInt As Integer = 50
Rem if its in phase of moving right
Dim MovRight As Boolean
Rem if its in phase of disappearing into right
Dim Disapear As Boolean
Rem if its in phase of reappearing from left
Dim StartAga As Boolean
Rem the length of caption
Dim CaptiLen As Integer
Rem default caption.
Dim DefCapti As String
Private Sub Form_Load()
CaptiLen = Len(Form1.Caption)
DefCapti = Form1.Caption
End Sub
Private Sub Start_Click()
MovRight = True
Disapear = False
StartAga = False
Timer1.Interval = TimerInt
End Sub
Private Sub Timer1_Timer()
Rem make i a loop variable
Static i As Integer
Rem if i is equal to capspace then start disapear phase
If i = CapSpace Then
i = 0
MovRight = False
Disapear = True
End If
Rem if still in movright phase and i < capspace then
If MovRight = True Then
Form1.Caption = Space(1) & Form1.Caption
Rem increase value of i one by one to make it equal to capspace
i = i + 1
End If
Rem if disapear phase (if the caption must disapear through right now)
If Disapear = True Then
Rem give caption 2 spaces from left and take one letter from right
Form1.Caption = Space(2) & Left(Form1.Caption, (Len(Form1.Caption) - 1))
End If
Rem if all of the visible (excluding spaces) caption has disappeared
If Len(Form1.Caption) = CaptiLen + CaptiLen + CapSpace Then
Disapear = False
Rem start the StartAgain phase
StartAga = True
End If
Rem if start again phase has started then
If StartAga = True Then
Static r
Rem make form1 caption to get each letter from right of the DefCapti.
Rem defcapti here helps us to reappear the true caption.
Rem if you don't like to use this easier way, the defcapti,
Rem you can count spaces and leave them off to take the cap.
Form1.Caption = Right(DefCapti, r)
r = r + 1
End If
Rem if form1 caption = the first caption then
If Form1.Caption = DefCapti Then
Rem r=0 so that the cap will not move forever in the 3rd loop.
r = 0
Rem start everything again....
Start_Click
End If
End Sub